package tools

func Polynomial(args []float64) Poly {
	return Poly(args)
}

type Poly []float64

func (p Poly) Evaluate(z float64) float64 {
	var result = p[len(p)-1]
	for i := len(p) - 1; i > 0; i-- {
		result *= z
		result += p[i-1]
	}
	return result
}

type CPoly []complex128

func (p CPoly) Evaluate(z complex128) complex128 {
	var result = p[len(p)-1]
	for i := len(p) - 1; i > 0; i-- {
		result *= z
		result += p[i-1]
	}
	return result
}
